package com.tianfang.mytranmqproducer.controller;

import com.tianfang.mytranmqproducer.model.TxMsg;
import com.tianfang.mytranmqproducer.service.TxMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TxMsgController {
    @Autowired
    private TxMsgService txMsgService;

    @RequestMapping(value="returnMsg")
    @ResponseBody
    public TxMsg returnMsg(){
        return txMsgService.getAllMsg();
    }

    @RequestMapping(value="returnMsg2")
    public String returnMsg2(Model model){
        TxMsg txMsg = txMsgService.getAllMsg();
        TxMsg txMsg2 = txMsgService.getFirstFieldMsg();
        model.addAttribute("txMsg1", txMsg);
        model.addAttribute("txMsg2", txMsg2);
        //转发
        return "helloPage";

        //重定向
        //return "redirect:helloPage.jsp";

    }
}
